#include<iostream>
using namespace std;

void test1()
{
	string s1;
	string s2;
	cin >> s1;
	s2 += s1;
	string ret = s1 + "hehe";
	cout << s1 << endl;
	cout << s2 << endl;
	cout << ret << endl;

	cout << s1.capacity() << endl  << ret.capacity() << endl;
}
void test2()
{
	string s1 = "hello world";
	string s2 = s1;
	//string::iterator it = s1.begin();
	auto it = s1.begin();
	while (it != s1.end())
	{
		cout << *it;
		++it;
	}
	for (size_t i = 0; i < s1.size(); ++i)
	{
		cout << s1[i];
	}
	for (auto& i : s1)
	{
		i = '0';
		cout << i;
	}
	cout << endl;
	string s3(s1, 6);
	for (auto& i : s3)
	{
		i = '0';
		cout << i;
	}
	cout << endl;
	string s4(s1.rbegin(), s1.rend());
	for (auto& i : s4)
	{
		i = '0';
		cout << i;
	}
	cout << s1.capacity() << endl;
	s1.clear();
	cout << s1.capacity() << endl;
	cout << s1.size() << endl;
	//auto it2 = s1.begin();
	//cout << *it2 << endl << *it << endl;
}
int main()
{
	test2();
	return 0;
}